package com.ymttest.database.sqlwapper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.YmtCouponGenerateSubTask;
import com.ymttest.utils.EnvSetup;

public class YmtCouponGenerateSubTaskWapper {
	SqlManager manager;

	public YmtCouponGenerateSubTaskWapper() {
		manager = new SqlManager("ymt" + EnvSetup.getEnv());
	}

	public List<YmtCouponGenerateSubTask> selectByTaskId(int taskId) {
		List<YmtCouponGenerateSubTask> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.YmtCouponGenerateSubTaskMapper.selectByTaskId",
						taskId);
		return result;
	}
	
	public List<YmtCouponGenerateSubTask> selectTop1() {
		List<YmtCouponGenerateSubTask> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.YmtCouponGenerateSubTaskMapper.selectTop1",
						null);
		return result;
	}
	
	public List<YmtCouponGenerateSubTask> selectTop1BySubTaskStatus(Integer subTaskStatus) {
		List<YmtCouponGenerateSubTask> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.YmtCouponGenerateSubTaskMapper.selectTop1BySubTaskStatus",
						subTaskStatus);
		return result;
	}
	
	
	public void setSubTaskStatus(int SubTaskId, int SubTaskStatus) {
		Map m = new HashMap();
		m.put("SubTaskId", SubTaskId);
		m.put("SubTaskStatus", SubTaskStatus);
		manager.update(
						"com.ymttest.database.mapping.YmtCouponGenerateSubTaskMapper.setSubTaskStatus",
						m);
		manager.commit();
	}
	
	public void setTaskId(int SubTaskId, int TaskId) {
		Map m = new HashMap();
		m.put("TaskId", TaskId);
		m.put("SubTaskId", SubTaskId);
		manager.update(
						"com.ymttest.database.mapping.YmtCouponGenerateSubTaskMapper.setTaskId",
						m);
		manager.commit();
	}
	
}
